﻿<Window x:Class="ProductManager.WPF.Presentation.Views.ShellWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:sys="clr-namespace:System;assembly=mscorlib"
        xmlns:p="clr-namespace:ProductManager.WPF.Presentation.Properties"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:vm="clr-namespace:ProductManager.WPF.Applications.ViewModels;assembly=ProductManager.WPF.Applications"
        mc:Ignorable="d" d:DataContext="{d:DesignInstance vm:ShellViewModel}"
        Title="{Binding Title}"
        Height="530" Width="900"
        Cursor="{Binding Path=UICursor}">
    
    <Window.InputBindings>
        <KeyBinding Command="{Binding SaveCommand}" Key="S" Modifiers="Control"/>
    </Window.InputBindings>

    <DockPanel>
        <Menu DockPanel.Dock="Top">
            <MenuItem Header="{x:Static p:Resources.DataMenu}">
                <MenuItem Command="{Binding SaveCommand}" Header="{x:Static p:Resources.SaveMenu}" Icon="{StaticResource SaveImage}" 
                          InputGestureText="{x:Static p:Resources.ControlS}"/>
                <Separator/>
                <MenuItem Command="{Binding ExitCommand}" Header="{x:Static p:Resources.ExitMenu}"/>
            </MenuItem>
            <MenuItem Header="{x:Static p:Resources.EditMenu}">
                <MenuItem Command="ApplicationCommands.Undo" Header="{x:Static p:Resources.UndoMenu}" Icon="{StaticResource UndoImage}"/>
                <MenuItem Command="ApplicationCommands.Redo" Header="{x:Static p:Resources.RedoMenu}" Icon="{StaticResource RedoImage}"/>
                <Separator/>
                <MenuItem Command="ApplicationCommands.Cut" Header="{x:Static p:Resources.CutMenu}" Icon="{StaticResource CutImage}"/>
                <MenuItem Command="ApplicationCommands.Copy" Header="{x:Static p:Resources.CopyMenu}" Icon="{StaticResource CopyImage}"/>
                <MenuItem Command="ApplicationCommands.Paste" Header="{x:Static p:Resources.PasteMenu}" Icon="{StaticResource PasteImage}"/>
                <MenuItem Command="EditingCommands.Delete" Header="{x:Static p:Resources.DeleteMenu}" Icon="{StaticResource DeleteImage}"/>
                <Separator/>
                <MenuItem Command="ApplicationCommands.SelectAll" Header="{x:Static p:Resources.SelectAllMenu}"/>
            </MenuItem>
            <MenuItem Header="{x:Static p:Resources.HelpMenu}">
                <MenuItem Command="{Binding AboutCommand}" Header="{x:Static p:Resources.AboutMenu}"/>
            </MenuItem>
        </Menu>

        <ToolBarTray Name="ToolBarTray" DockPanel.Dock="Top">
            <ToolBar>
                <Button Command="{Binding SaveCommand}" Content="{StaticResource SaveImage}" ToolTip="{x:Static p:Resources.Save}"/>
                <Separator/>
                <Button Command="ApplicationCommands.Undo" Content="{StaticResource UndoImage}" ToolTip="{x:Static p:Resources.Undo}"/>
                <Button Command="ApplicationCommands.Redo" Content="{StaticResource RedoImage}" ToolTip="{x:Static p:Resources.Redo}"/>
                <Button Command="ApplicationCommands.Cut" Content="{StaticResource CutImage}" ToolTip="{x:Static p:Resources.Cut}"/>
                <Button Command="ApplicationCommands.Copy" Content="{StaticResource CopyImage}" ToolTip="{x:Static p:Resources.Copy}"/>
                <Button Command="ApplicationCommands.Paste" Content="{StaticResource PasteImage}" ToolTip="{x:Static p:Resources.Paste}"/>
            </ToolBar>
        </ToolBarTray>

        <StatusBar DockPanel.Dock="Bottom">
            <StatusBarItem Content="{x:Static p:Resources.Ready}"/>
        </StatusBar>

        <TabControl Name="TabControl">
            <TabItem Name="ProductTab"> <!-- Header="{x:Static p:Resources.Products}" -->
                <TabItem.Header>
                    <StackPanel Orientation="Horizontal">
                        <!-- header text-->
                        <TextBlock VerticalAlignment="Center" >
                            <Bold><TextBlock Text="{x:Static p:Resources.Products}"/></Bold>
                        </TextBlock>
                        
                        <!-- changes marker -->
                        <ContentControl>
                            <ContentControl.Content>
                                <PriorityBinding>
                                    <Binding Path="DataContext" RelativeSource="{RelativeSource Self}" />
                                </PriorityBinding>
                            </ContentControl.Content>
                            <ContentControl.ContentTemplate>
                                <DataTemplate>
                                    <Image Name="editedImage" Source="../Resources/Images/Edit.png" Width="14" Height="14" Margin="2 -1 -1 -1" ToolTip="{x:Static p:Resources.Edited}" Visibility="Hidden" />
                                    <DataTemplate.Triggers>
                                        <DataTrigger Binding="{Binding ProductHasChanges}" Value="True" >
                                            <Setter Property="Visibility" Value="Visible" TargetName="editedImage" />
                                        </DataTrigger>
                                    </DataTemplate.Triggers>
                                </DataTemplate>
                            </ContentControl.ContentTemplate>
                        </ContentControl>
                    </StackPanel>
                </TabItem.Header>
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="Auto" />
                    </Grid.ColumnDefinitions>

                    <ContentControl Name="ProductListViewContentControl" Content="{Binding ProductListView}" Grid.Column="0" Margin="0,0,7,0"/>

                    <!--<GridSplitter HorizontalAlignment="Right" VerticalAlignment="Stretch" Width="4" Grid.Row="0" Grid.Column="0"/>-->

                    <ContentControl x:Name="productViewPresenter" Content="{Binding ProductView}" Grid.Column="1" />
                </Grid>
            </TabItem>
        </TabControl>

    </DockPanel>

</Window>
